<?php
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_movies.php';
$number = filter_input(INPUT_POST, "number");
?>
<script type="text/javascript">
    $(document).ready(function() {
        $('.ui .item').on('click', function() {
            $('.ui .item').removeClass('active');
            $(this).addClass('active');
        });
        $('.ui.dropdown').dropdown({
            on: 'hover'
        });
    });
</script>
    <form name="form_add_data" id="form_add_data" method="POST" action="?" enctype="multipart/form-data">
<?php
for ($index = 0; $index < $number; $index++) {?>
    <div class="ui form segment form-background">
        <input type="hidden" name="index<?php echo $index; ?>" value="1" />

        <div class="field">
            <label for="Title">Title <span class="required">*</span></label>
            <input id="Title" name="Title<?php echo $index; ?>" value="" placeholder="Title" type="text">
        </div>

        <div class="field">
            <label for="Status">Status</label>
            <div class="ui selection dropdown">
                <input type="hidden" name="Status<?php echo $index; ?>" value="">
                <?php 
                $status = api_movies::get_default_movie_statuses();
                ?>
                <div class="text"><?php echo $status; ?></div>
                <i class="dropdown icon"></i>
                <div class="menu ui transition hidden">
                  <?php 

                    $list = api_movies::get_all_movie_statuses();
                    $text = "";
                    if (!empty($list) && count($list) > 0) {
                        foreach ($list as $item) {?>
                            <div class="item"><?php echo $item['name']; ?></div>
                  <?php
                        } 
                    }?>
                </div>
              </div>
        </div>

        <div class="field">
            <label for="Description">Description <span class="required">*</span></label>
            <textarea id="Description" name="Description<?php echo $index; ?>" placeholder="Description" class="form-control" rows="3"></textarea>
        </div>

        <div class="field">
            <label for="Poster">Poster <span class="required">*</span></label>

            <input type="file" name="File_Poster<?php echo $index; ?>" />
        </div>

    </div>
    <br/>
<?php
}
?>
    <div class="ui form segment form-background">
        <input type="hidden" name="Action" value="">
        <div class="ui buttons">
            <a href="?"><div class="ui  button">Cancel</div></a>
            <div class="or"></div>
            <div id="action-add-button" class="ui orange button" onclick="submit_add_data();">Add All</div>
        </div>
    </div>
    
    </form>
